#include <bits/stdc++.h>
using namespace std;
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
using ll = long long;
set<ll> st;
ll opt, t;
void solve()
{

    cin >> opt >> t;
    if (opt == 1)
    {
        if (st.insert(t).second == false)
        {
            cout << "Already Exist" << endl;
        }
    }
    else
    {
        if (st.empty())
        {
            cout << "Empty" << endl;
            return;
        }
        if (st.find(t) != st.end())
        {
            st.erase(st.find(t));
            cout << t << endl;
            return;
        }
         auto now = st.lower_bound(t);
         auto l = now, r = now;
         if (now == st.begin())
         {
             cout << *now << endl;
             st.erase(now);
             return;
         }
        else if (now == st.end())
        {
            cout << *(--now)<< endl;
            st.erase(now);
            return;
        }
        else if (*now - t < t - *(--r))
        {
            cout << *(now) << endl;
            st.erase(now);
        }
        else
        {
            cout << *(--now) << endl;
            st.erase(now);
        }
    }
}
int main()
{
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
